package cn.jiyun.controller;

import cn.jiyun.entity.PageResult;
import cn.jiyun.entity.QueryPageBean;
import cn.jiyun.entity.Result;
import cn.jiyun.pojo.Dd;
import cn.jiyun.service.DdService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dd")
public class DdController {
    @Reference
    private DdService ddService;
    @RequestMapping("/findPage")

    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return ddService.findPage(queryPageBean);
    }
    @RequestMapping("/add")
    public Result add(@RequestBody Dd dd){

        try {
            ddService.add(dd);
            return new Result(true,"成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result(false,"失败");
    }
    @RequestMapping("/update")
    public Result update(@RequestBody Dd dd){

        try {
            ddService.update(dd);
            return new Result(true,"成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result(false,"失败");
    }
    @RequestMapping("/delete")
    public Result delete(Integer id){


        try {
            ddService.delete(id);
            return new Result(true,"成功");

        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"失败");

        }

    }




}
